//
//  LHVisitorController.swift
//  sina_weibo
//
//  Created by 刘刘海强 on 16/5/11.
//  Copyright © 2016年 chuanzhi. All rights reserved.
//

import UIKit

class LHVisitorController: UITableViewController {
    
    //用户是否登录的视图
    var userLogin = LHUserAccountModel.sharedUserAccount.isLogin
    
    var vistorView: LHVisitorView?

    override func viewDidLoad() {
        super.viewDidLoad()
        
        
    }
    
    override func loadView() {
        
        if userLogin {
            super.loadView()
        }else{
            vistorView = LHVisitorView()
            vistorView?.callBackClosure = {[weak self] in
                self?.oauthLogin()
            }
            view = vistorView
            setupNavUI()
        }
        
    }

    func setupNavUI() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", fontSize: 15, target: self, action: "registerClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", fontSize: 15, target: self, action: "loginClick")
    
    }
    
    @objc private func registerClick() {
        oauthLogin()
    }
    
    @objc private func loginClick() {
        oauthLogin()
    }
    
    @objc private func oauthLogin() {
        let oauthController = LHOAuthController()
        let nav = UINavigationController(rootViewController: oauthController)
        presentViewController(nav, animated: true, completion: nil)
    }
   
}
